﻿@model AdminContentViewModel

@{
    ViewBag.Title = "Content";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<h2>Content</h2>
@Html.ActionLink("Create Content", "CreateContent")
<br/><br/>
@using (Html.BeginForm("Content", "Admin", FormMethod.Post)) {
	<label>Select content place: </label>@Html.DropDownListFor(x => x.ContentPlace, Model.Filters, new { onchange = "$(this).closest('form').submit();" })
}
<br/><br/>
<table>
	<tr>
		<th>Id</th>
		<th>Title</th>
		<th>Created Date</th>
		<th>Content Place Name</th>
		<th>Content Place Type</th>
		<th>Description</th>
		<th>Actions</th>
	</tr>
	@foreach (var item in Model.Items) {
		<tr>
			<td>@item.Id</td>
			<td>@item.DefaultContent.Title</td>
			<td>@item.CreateDate.ToString()</td>
			<td>@item.ContentPlace.Name</td>
			<td>@item.ContentPlace.KeyName</td>
			<td>@item.DefaultContent.Description</td>
			<td>
				@Html.ActionLink("Edit", "EditContent", new { id = item.Id }, new {style = "float: left;"})
				@using (Html.BeginForm("DeleteContentItem", "Admin", new {id = item.Id}, FormMethod.Post, new {style = "float: left; margin-left: 10px;"})) {
					<input type="submit" value="Delete"/>
					@Html.HttpMethodOverride(HttpVerbs.Delete)
				}
			</td>
		</tr>
	}
</table>